<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Title</title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
			.father {
				width: 400px;
				height: 400px;
				background-color: pink;
				position: relative;
				margin: 100px;
			}
			.son {
				width: 200px;
				height: 200px;
				background-color: red;
				position: absolute;
				top: 100px;
				left: 100px;
				
			}
		</style>
	</head>
	<body>
		<div class="father">
			<div class="son"></div>
		</div>
		<script src="jquery-1.12.4.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function(){
				//获取元素的相对document的位置
				console.log($(".son").offset());
				
				//获取元素的相对于有定位的父元素的位置
				console.log($(".son").position());
			});
		</script>
	</body>
</html>